<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>主播用户管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			/* $("#btnExport").click(function(){
				top.$.jBox.confirm("确认要导出用户数据吗？","系统提示",function(v,h,f){
					if(v=="ok"){
						$("#searchForm").attr("action","${ctx}/sys/user/export");
						$("#searchForm").submit();
					}
				},{buttonsFocus:1});
				top.$('.jbox-body .jbox-icon').css('top','55px');
			});
			$("#btnImport").click(function(){
				$.jBox($("#importBox").html(), {title:"导入数据", buttons:{"关闭":true}, 
					bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
			}); */
		});
		function page(n,s){
			if(n) $("#pageNo").val(n);
			if(s) $("#pageSize").val(s);
			$("#searchForm").attr("action","${ctx}/sys/user/userAccountList");
			$("#searchForm").submit();
	    	return false;
	    }
	
		
		function openDialog(userId){
/* 			if(!confirmx('确认要为该用户手工充值吗？')){
				return false;
			} */
			$("#userId").val(userId);
			$("#dialog").dialog({
			bgiframe: true,
	        resizable: true, //是否可以重置大小
	        height: 300, //高度
	        width: 550, //宽度
	        draggable: false, //是否可以拖动。
	        title: "手工充值",
	        modal: true,
	        close: function() {
	        	window.location.reload();
	         },
	        show : {
				effect : 'drop',
				direction : 'up'
			}
			});
		};
		function close(){
			$("#dialog").dialog("close");
		};

	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/sys/user/userAccountList">用户列表</a></li>
		<%-- <shiro:hasPermission name="sys:user:edit"><li><a href="${ctx}/sys/user/userAccountForm">账户修改</a></li></shiro:hasPermission>
	 --%></ul>
	<form:form id="searchForm" modelAttribute="user" action="${ctx}/sys/user/userAccountList" method="post" class="breadcrumb form-search ">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<sys:tableSort id="orderBy" name="orderBy" value="${page.orderBy}" callback="page();"/>
		<ul class="ul-form">
		  <li><label>用户分类：</label>
				<form:select path="authenStatus" class="input-medium">
					<form:option value="" label="全部"/>
					<form:options items="${fns:getDictList('USER_TYPE')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</li>
			<li><label>用户ID：</label><form:input path="id" htmlEscape="false" maxlength="50" class="input-medium"/></li>
			<li><label>用户姓名：</label><form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/></li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询" onclick="return page();"/>
			</li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
		<tr>
	    <th>用户ID</th>
		<th class="sort-column name">姓名</th>
		<th>手机</th>
	    <th>邮箱</th>
		<th>播豆</th>
		<th>余额</th>
		<th>经验值</th>
		<th>等级</th>
		<shiro:hasPermission name="sys:user:edit"><th>操作</th></shiro:hasPermission></tr></thead>
		<tbody>
		<c:forEach items="${page.list}" var="user">
			<tr>
			   <td><a href="${ctx}/sys/user/form?id=${user.id}">${user.id}</a></td>
				<td>${user.name}</td>
				<td>${user.mobile}</td> 
				<td>${user.email}</td>  
				<td>${user.gold}</td>  
				<td>${user.account}</td>  
				<td>${user.empiricalValue}</td>  
				<td>${user.level}</td>  
				<shiro:hasPermission name="sys:user:edit">
				<td>
					<a href="javascript:;" onclick="openDialog('${user.id}');">充值</a>
					<c:if test="${user.account>0}">
						<a href="${ctx}/sys/user/userAccountConvert?id=${user.id}">转为播豆</a>
					</c:if>
    				<a href="${ctx}/sys/user/userAccountForm?id=${user.id}" onclick="return confirmx('确认要手工修改用户账务信息吗？', this.href)">修改账务</a>
				</td>
				</shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	
	<div style="display:none;overflow:hidden;padding:3px" id="dialog">
		 <form:form id="formResult" action="${ctx}/sys/user/userRecharge" method="post"
		class="form-horizontal">
		<input type="hidden" name="userId" id="userId"  /> 
		<br />
	   <div class="control-group">
			<label class="control-label">备注说明:</label>
			<div class="controls">1元 = ${goldRate} 个播豆</div>
		</div>
		 <div class="control-group">
			<label class="control-label">充值金额（元）:</label>
			<div class="controls">
				<input name="amount" id="amount" class="required" />
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">播豆直充:</label>
			<div class="controls">
				<input name="checkGold" id="checkGold" type="checkbox" checked="checked" value="1" />
			</div>
		</div>
		<div class="form-actions">
			 <input id="btnSubmitRecharge" class="btn btn-primary" type="button"
					value="保 存" /> &nbsp;&nbsp;
			  <input id="btnCancel" class="btn" type="button" value="取 消" />
		</div>
		</form:form>
	</div>
	<script type="text/javascript" >
	 $("#btnCancel").click(function(){
		 $("#dialog").dialog("close");
	 });
	
	$("#btnSubmitRecharge").click(function(){
		var postData = $("#formResult").serialize();
		var url = $("#formResult").attr("action");
		$.post(url, postData).done(function(data) {
			if (data.indexOf("success")>-1) {
				alert("提交成功");
			} else {
				alert("提交失败");
			}
			close();
		});
		/*  $("#formResult").validate({ 
			submitHandler : function(form) {
				loading('正在提交，请稍等...');
				
			},
			errorContainer : "#messageBox",
			errorPlacement : function(error, element) {
				$("#messageBox").text("输入有误，请先更正。");
				if (element.is(":checkbox")
						|| element.is(":radio")
						|| element.parent().is(".input-append")) {
					error.appendTo(element.parent().parent());
				} else {
					error.insertAfter(element);
				}
			}
		});  */
		
	
	});
	
	</script>
</body>
</html>